package com.wc.codeforces.思维.Hungry_Games;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/7/18 23:10
 * @description https://codeforces.com/contest/1994/problem/C
 */
public class Main {
    /**
     * 思路：记忆化搜索的二分
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static long[] s = new long[N];
    // f[i] 表示 l = i的个数
    static long[] f = new long[N];
    static int n, x;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            x = sc.nextInt();
            for (int i = 1; i <= n; i++) {
                s[i] = s[i - 1] + sc.nextInt();
                f[i] = -1;
            }
            long res = 0;
            for (int i = 1; i <= n; i++) {
                f[i] = check(i, i - 1, n);
                res += f[i];
            }

            out.println(res);
        }
        out.flush();
    }

    static long check(int u, int l, int r) {
        if (l > r || u > n) return 0;
        if (f[u] != -1) return f[u];
        while (l < r) {
            int mid = l + r + 1 >> 1;
            if (s[mid] - s[u - 1] <= x) l = mid;
            else r = mid - 1;
        }
        f[u] = r - (u - 1);
        // 这个是表示 r 是满足s[r] - s[u - 1] <= x, s[r + 1] - s[u - 1] > x, s[r + 2] - s[u - 1] = 0, 也就是check(r + 1, n, r + 2)
        f[u] += check(r + 2, r + 1, n);
        return f[u];
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
